package com.wanhe.viewconf;

import com.wanhe.base.model.base.Dish;
import com.wanhe.viewconf.views.child.BaseXYView;
import com.wanhe.viewconf.views.child.MealBookChildItemView;

/**
 * Created by cdj on 2017/7/7.
 */

public class ViewOptions {

    private final OnCounterViewClickListener mCounterViewClick;
    private final OnViewNormalClickListener mViewNormalClick;

    private ViewOptions(Builder b) {

        /**
         *
         * 将Builder中的信息进行提取
         *
         * @author 陈德基
         * @time 2017/7/7 10:11
         */
        this.mCounterViewClick = b.mViewClickListener;
        this.mViewNormalClick = b.mNormalViewClickListener;

    }

    public OnCounterViewClickListener getCounterViewClick() {
        return mCounterViewClick;
    }

    public OnViewNormalClickListener getViewNormalClick() {
        return mViewNormalClick;
    }

    private static Builder builder;

    public static Builder builder() {
        if (builder == null) {
            synchronized (Builder.class) {
                if (builder == null) {
                    builder = new Builder();
                }
            }
        }
        return builder;
    }

    public static class Builder {

        private OnCounterViewClickListener mViewClickListener;
        private OnViewNormalClickListener mNormalViewClickListener;


        public ViewOptions build() {
            return new ViewOptions(this);
        }

        public Builder setCounterViewClickListener(OnCounterViewClickListener listener) {
            this.mViewClickListener = listener;
            return this;
        }

        public Builder setViewNormalClickListener(OnViewNormalClickListener listener) {
            this.mNormalViewClickListener = listener;
            return this;
        }
    }

    /**
     * File Name:ViewFactoryConfig.java<br/>
     * Package Name:com.wanhe.viewconf<br/>
     * Date:2017/7/6 21:24<br/>
     * author:chendeji<br/>
     * desc: 通用的view点击进行的数据反馈<br/>
     * Copyright (c) 2017/7/6, 781571323@qq.com All Rights Reserved.
     */
    public interface OnViewNormalClickListener {

        int CLICK = 0;
        int LONG_CLICK = 1;

        /**
         * Methor Name:cartChangeReceiveXY<br/>
         * Package Name:com.wanhe.viewconf<br/>
         * Date:2017/7/10 10:35<br/>
         * author:chendeji<br/>
         * desc: 控件的中心点屏幕坐标<br/>
         * Copyright (c) 2017/7/10, 781571323@qq.com All Rights Reserved.
         *
         * @param view 被点击控件
         * @param x    横坐标坐标
         * @param y    纵坐标
         * @return
         */
        void cartChangeReceiveXY(BaseXYView view, int x, int y);


        /**
         * Methor Name:operationView<br/>
         * Package Name:com.wanhe.viewconf<br/>
         * Date:2017/7/10 10:38<br/>
         * author:chendeji<br/>
         * desc: 点击控件后需要做的其他扩展操作<br/>
         * Copyright (c) 2017/7/10, 781571323@qq.com All Rights Reserved.
         *
         * @param view   被点击控件
         * @param opType {@link OnViewNormalClickListener#CLICK} 点击操作
         * {@link OnViewNormalClickListener#LONG_CLICK} 长按操作<br/>
         * @return
         */
        void operationView(BaseXYView view, int opType);
    }

    /**
     * File Name:ViewFactoryConfig.java<br/>
     * Package Name:com.wanhe.viewconf<br/>
     * Date:2017/7/5 17:28<br/>
     * author:chendeji<br/>
     * desc: 对外暴露菜品添加器的操作接口<br/>
     * Copyright (c) 2017/7/5, 781571323@qq.com All Rights Reserved.
     */
    public interface OnCounterViewClickListener {
        void plus(MealBookChildItemView view, Dish dish);

        void reduce(MealBookChildItemView view, Dish dish);
    }
}
